home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / DevCon / Milan_1991 / Devcon91.4 / AppShell / Examples / MultiProj / about.c next >
Encoding:
C/C++ Source or Header  |  1992-09-01  |  5.7 KB  |  183 lines

  1. /*************************************************************************
  2.   *                                                                      *
  3.   *                            Preliminary                               *
  4.   *                        Amiga AppShell (tm)                           *
  5.   *                                                                      *
  6.   *  Copyright (c) 1990,1991 Commodore-Amiga, Inc. All Rights Reserved.  *
  7.   *                                                                      *
  8.   *   This software and information is proprietary, preliminary, and     *
  9.   *   subject to change without notice.                                  *
  10.   *                                                                      *
  11.   *                            DISCLAIMER                                *
  12.   *                                                                      *
  13.   *   THIS SOFTWARE IS PROVIDED "AS IS".                                 *
  14.   *   NO REPRESENTATIONS OR WARRANTIES ARE MADE WITH RESPECT TO THE      *
  15.   *   ACCURACY, RELIABILITY, PERFORMANCE, CURRENTNESS, OR OPERATION      *
  16.   *   OF THIS SOFTWARE, AND ALL USE IS AT YOUR OWN RISK.                 *
  17.   *   NEITHER COMMODORE NOR THE AUTHORS ASSUME ANY RESPONSIBILITY OR     *
  18.   *   LIABILITY WHATSOEVER WITH RESPECT TO YOUR USE OF THIS SOFTWARE.    *
  19.   *                                                                      *
  20.   *                          Non-Disclosure                              *
  21.   *                                                                      *
  22.   *   This information is not to be disclosed to any other company,      *
  23.   *   individual or party.  Discussion is to be restricted to CBM        *
  24.   *   approved discussion areas, such as the closed conferences on bix;  *
  25.   *   amiga.cert, amiga.com, amiga.beta/appshell.                        *
  26.   *                                                                      *
  27.   ************************************************************************
  28.   */
  29.  
  30. /* about.c
  31.  * Copyright (C) 1991 Commodore-Amiga, Inc.
  32.  * About requester for a multi-project applicaton
  33.  * Written by David N. Junod
  34.  *
  35.  * Must be compiled with Lattice options: -b0 -cfist -ms -v
  36.  *
  37.  */
  38.  
  39. #include "multiproj.h"
  40.  
  41. STRPTR about_text[] =
  42. {
  43.  /* Padding */
  44.     "",
  45.  
  46.     "About MultiProj",
  47.     APPNAME,
  48.     APPVERS,
  49.     APPCOPY,
  50.     APPAUTH,
  51.     "_Continue",
  52.  
  53.     "<no ARexx port>",
  54.     NULL
  55. };
  56.  
  57. struct TagItem icon_tags[] =
  58. {
  59.     {CGTA_MaxWidth, 80},
  60.     {CGTA_MaxHeight, 40},
  61.     {CGTA_LabelInfo, LABEL_CENTER},
  62.     {CGTA_FrameInfo, FRAME_CENTER},
  63.     {TAG_DONE,},
  64. };
  65.  
  66. extern struct TagItem td_tags[];
  67.  
  68. struct TagItem text_tags[] =
  69. {
  70.     {CGTA_Borderless, TRUE},
  71.     {GA_TEXT, NULL},
  72.     {TAG_DONE,},
  73. };
  74.  
  75. /* MAIN window environment */
  76. /* This is the object array for the About window. */
  77. struct Object about[] =
  78. {
  79.     {&about[1], 0, 0, OBJ_Window, NULL, APSH_OBJF_LOCALTEXT, NULL, "About", 1L,
  80.      {1, 1, 0, 0},},
  81.  
  82.     {&about[2], 0, 0, OBJ_Display, NULL, NULL, NULL, "Icon", 0L,
  83.      {8, 4, 90, 44}, icon_tags,},
  84.  
  85.  /* Using the Label as the contents... */
  86.     {&about[3], 0, 0, OBJ_Text, NULL, APSH_OBJF_LOCALTEXT, NULL, "Name", 2L,
  87.      {116, 4, 320, 10}, td_tags,},
  88.  
  89.     {&about[4], 0, 0, OBJ_Text, NULL, APSH_OBJF_LOCALTEXT, NULL, "Copyright", 3L,
  90.      {116, 14, 320, 10}, td_tags,},
  91.  
  92.     {&about[5], 0, 0, OBJ_Text, NULL, APSH_OBJF_LOCALTEXT, NULL, "Version", 4L,
  93.      {116, 24, 320, 10}, td_tags,},
  94.  
  95.     {&about[6], 0, 0, OBJ_Text, NULL, APSH_OBJF_LOCALTEXT, NULL, "Author", 5L,
  96.      {116, 34, 320, 10}, td_tags,},
  97.  
  98.     {&about[7], 0, 0, OBJ_Display, NULL, NULL, NULL, "ARexx", NULL,
  99.      {116, 44, 320, 10}, text_tags,},
  100.  
  101.     {NULL, 0, 0, OBJ_Button, NULL, APSH_OBJF_LOCALTEXT | APSH_OBJF_CLOSEWINDOW,
  102.      NULL, "Continue", 6L, {-94, 58, 80, 12},},
  103. };
  104.  
  105. /* This is the Window Environment tag array for the About window. */
  106. struct TagItem aboutenv[] =
  107. {
  108.     {APSH_NameTag, (ULONG) "About"},    /* name to give to window */
  109.     {APSH_Objects, (ULONG) about},    /* object list */
  110.     {APSH_WinText, (ULONG) about_text},
  111.     {APSH_WinAOpen, OpenAboutID},
  112.     {TAG_DONE,}
  113. };
  114.  
  115. VOID PAboutFunc (struct Hook *h, struct AppInfo *ai, struct AppFunction *af)
  116. {
  117.     /* open the About window */
  118.     HandlerFunc (ai,
  119.          APSH_Handler, "IDCMP",
  120.          APSH_Command, APSH_MH_OPEN,
  121.          APSH_WindowEnv, (ULONG) aboutenv,
  122.          TAG_DONE);
  123.  
  124. }
  125.  
  126. VOID
  127. OpenAboutFunc (struct Hook *h, struct AppInfo *ai, struct AppFunction *af)
  128. {
  129.     struct AppData *ad = (struct AppData *) ai->ai_UserData;
  130.     STRPTR port_name = about_text[7];
  131.     struct MsgHandler *mh;
  132.     struct Window *win;
  133.     struct Gadget *gad;
  134.  
  135.     /* See if we have a tool icon */
  136.     if (ai->ai_ProgDO)
  137.     {
  138.     struct Image *im;
  139.  
  140.     im = (struct Image *) (ai->ai_ProgDO->do_Gadget.GadgetRender);
  141.  
  142.     /* Update the imagry */
  143.     if (APSHGetGadgetInfo (ai, "About", "Icon",
  144.                    (ULONG *) & win, (ULONG *) & gad))
  145.     {
  146.         /* Let the gadget know that there is an image */
  147.         SetGadgetAttrs (gad, win, NULL,
  148.                 GA_LABELIMAGE, im, TAG_DONE);
  149.     }
  150.     }
  151.     else
  152.     {
  153.     /* Update the imagry to show the program name */
  154.     if (APSHGetGadgetInfo (ai, "About", "Icon",
  155.                    (ULONG *) & win, (ULONG *) & gad))
  156.     {
  157.         /* Let the gadget know that there is an image */
  158.         SetGadgetAttrs (gad, win, NULL,
  159.                 GA_TEXT, ai->ai_ProgName, TAG_DONE);
  160.     }
  161.     }
  162.  
  163.     /* See if we have an ARexx port */
  164.     if (mh = HandlerData (ai, APSH_Handler, "AREXX", TAG_DONE))
  165.     {
  166.     /* Get a pointer to the port name */
  167.     port_name = mh->mh_PortName;
  168.     }
  169.  
  170.     /* Get a pointer to the ARexx port name text gadget */
  171.     if (APSHGetGadgetInfo (ai, "About", "ARexx",
  172.                (ULONG *) & win, (ULONG *) & gad))
  173.     {
  174.     /* Build the description string */
  175.     sprintf (ad->ad_Tmp, "ARexx port: %s", port_name);
  176.  
  177.     /* Update the string gadget */
  178.     SetGadgetAttrs (gad, win, NULL,
  179.                GA_Text, ad->ad_Tmp,
  180.                TAG_DONE);
  181.     }
  182. }
  183.